package com.xd.study.activity;

import android.app.Activity;
import android.os.Bundle;
import android.widget.SeekBar;
import android.widget.TextView;

import com.xd.study.R;

/**
 * Created by DGF on 2015/4/29.
 */
public class SeekBarActivity extends Activity {

    private TextView textView1;
    private TextView textView2;
    private SeekBar seekbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.seekbar);

        seekbar = (SeekBar)this.findViewById(R.id.seekbar);
        textView1 = (TextView)this.findViewById(R.id.seekbar_text1);
        textView2 = (TextView)this.findViewById(R.id.seekbar_text2);

        /**
         * 监听SeekBar
         */
        seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            /**
             * 数值改变
             * @param seekBar
             * @param progress
             * @param fromUser
             */
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                textView1.setText("正在拖动");
                textView2.setText("当前数值："+progress);
            }

            /**
             * 开始拖动
             * @param seekBar
             */
            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
                textView1.setText("开始拖动");
            }

            /**
             * 停止拖动
             * @param seekBar
             */
            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                textView1.setText("停止拖动");
            }
        });
    }
}
